package org.dpms.config;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.plugins.PerformanceInterceptor;


	@Configuration
	@MapperScan("org.dpms.dao")
	public class MybatisPlusConfig {
	   /*
	    * 分页插件，自动识别数据库类型
	    */
	   @Bean
	   public PaginationInterceptor paginationInterceptor() {
		   PaginationInterceptor page = new PaginationInterceptor();
	        page.setDialectType("mysql");
	        return page;
	   }
	   
	   /**
	     * mybatis-plus SQL执行效率插件【生产环境可以关闭】
	     */
	    @Bean
	    public PerformanceInterceptor performanceInterceptor() {
	        return new PerformanceInterceptor();
	    }


	   /*
	    * oracle数据库配置JdbcTypeForNull
	    * 参考：https://gitee.com/baomidou/mybatisplus-boot-starter/issues/IHS8X
	    不需要这样配置了，参考 yml:
	    mybatis-plus:
	      confuguration
	        dbc-type-for-null: 'null' 
	   @Bean
	   public ConfigurationCustomizer configurationCustomizer(){
	       return new MybatisPlusCustomizers();
	   }

	   class MybatisPlusCustomizers implements ConfigurationCustomizer {

	       @Override
	       public void customize(org.apache.ibatis.session.Configuration configuration) {
	           configuration.setJdbcTypeForNull(JdbcType.NULL);
	       }
	   }
	   */
	}
